import java.io.*;

class ExerciseOne {
    private int[][] arrayForOutput;

    static public void main(String args[]) {
        ExerciseOne test = new ExerciseOne();
        test.doTest();
    }

    public void doTest() {
        try {
            generateArrayForOutput(getInputDimension());
            outputArray();
        } catch (Exception e) {
            System.out.println("Application teminated abnormally.");
            e.printStackTrace();
        }
    }

    private int getInputDimension() throws IOException, NumberFormatException{
        try {
            BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("Enter an integer:");
            String inputedIntegerString = stdin.readLine();
            int dimension = Integer.parseInt(inputedIntegerString);
            return dimension;
        } catch (IOException e) {
            System.out.println("Standard Input Error!");
            throw e;
        } catch (NumberFormatException e) {
            System.out.println("What you inputed is not a integer!");
            throw e;
        }
    }

    private void generateArrayForOutput(int dimension) {
        arrayForOutput = new int[dimension][dimension];
        StateManager stateManager = new StateManager(0, dimension - 1);

        while (stateManager.canStep()) {
            stateManager.step();
            Position positionNow = stateManager.getPosition();
            arrayForOutput[positionNow.getRowIndex()][positionNow.getColumnIndex()] = stateManager.getFiller();
        }
    }

    private void outputArray() {
        for (int[] row : arrayForOutput) {
            for (int integer : row) {
                System.out.print(String.valueOf(integer) + "\t");
            }
            System.out.print("\n");
        }
    }
}

class Position {
    private int columnIndex;
    private int rowIndex;

    public Position(int _column, int _row) {
        this.columnIndex = _column;
        this.rowIndex = _row;
    }

    public int getColumnIndex() {
        return this.columnIndex;
    }

    public int getRowIndex() {
        return this.rowIndex;
    }

    public void walkRight() {
        ++ columnIndex;
    }

    public void walkLeft() {
        -- columnIndex;
    }

    public void walkDown() {
        ++ rowIndex;
    }

    public void walkUp() {
        -- rowIndex;
    }
}

class StateManager {
    abstract class State {
        protected int upperBound;
        protected int lowerBound;
        protected Position position;

        abstract public State step();

        public State(int _lower, int _upper) {
            this.upperBound = _upper;
            this.lowerBound = _lower;
            position = new Position(0, 0);
        }

        public State(State originState) {
            this.upperBound = originState.getUpperBound();
            this.lowerBound = originState.getLowerBound();
            this.position = originState.getPosition();
        }

        public int getUpperBound() {
            return this.upperBound;
        }

        public int getLowerBound() {
            return this.lowerBound;
        }

        public Position getPosition() {
            return this.position;
        }
    }

    class WalkRightState extends State {
        public WalkRightState(int _upper, int _lower) {
            super(_upper, _lower);
        }

        public WalkRightState(State originState) {
            super(originState);
        }

        public State step() {
            this.position.walkRight();

            if (this.upperBound == this.position.getColumnIndex()) {
                return new WalkDownState(this);
            } else {
                return this;
            }
        }
    }

    class WalkDownState extends State {
        public WalkDownState(int _upper, int _lower) {
            super(_upper, _lower);
        }

        public WalkDownState(State originState) {
            super(originState);
        }

        public State step() {
            this.position.walkDown();

            if (this.upperBound == this.position.getRowIndex()) {
                return new WalkLeftState(this);
            } else {
                return this;
            }
        }
    }

    class WalkLeftState extends State {
        public WalkLeftState(int _upper, int _lower) {
            super(_upper, _lower);
        }

        public WalkLeftState(State originState) {
            super(originState);
        }

        public State step() {
            this.position.walkLeft();

            if (this.lowerBound == this.position.getColumnIndex()) {
                return new WalkUpState(this);
            } else {
                return this;
            }
        }
    }

    class WalkUpState extends State {
        public WalkUpState(int _upper, int _lower) {
            super(_upper, _lower);
        }

        public WalkUpState(State originState) {
            super(originState);
        }

        public State step() {
            this.position.walkUp();

            if ((this.lowerBound + 1) == this.position.getRowIndex()) {
                ++ this.lowerBound;
                -- this.upperBound;

                return new WalkRightState(this);
            } else {
                return this;
            }
        }
    }

    private State state;
    private int lowerBound;
    private int upperBound;
    private int stepCount;
    private final int MAXIMUM_STEP;

    public StateManager(int _lower, int _upper) {
        this.lowerBound = _lower;
        this.upperBound = _upper;
        this.stepCount = 0;
        this.MAXIMUM_STEP = (_upper - _lower + 1) * (_upper - _lower + 1);
    }

    public Position getPosition() {
        return this.state.getPosition();
    }

    public void step() {
        ++ this.stepCount;

        if (null == this.state) {
            this.state = new WalkRightState(lowerBound, upperBound);
        } else {
            this.state = this.state.step();
        }
    }

    public boolean canStep() {
        return (this.MAXIMUM_STEP > this.stepCount);
    }

    public int getFiller() {
        return this.stepCount;
    }
}
